package com.easybuy.service.NewsSerivce;

import com.easybuy.Tools.Page;
import com.easybuy.dao.NewsMapper;
import com.easybuy.pojo.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsSerivce {
    @Autowired
    private NewsMapper newsMapper;

    @Override
    public int addNews(News news) {
        return newsMapper.addNews(news);
    }

    @Override
    public News getNews(int id) {
        return newsMapper.selectById(id);
    }

    @Override
    public Page<News> newsList(Page page) {
        page.setPageCount(newsMapper.selectCount());
        page.setList(newsMapper.newsList(page));
        return page;
    }

    @Override
    public int modifyNews(News news) {
        return newsMapper.modifyNews(news);
    }

    @Override
    public int deleNews(int id) {
        return newsMapper.deleNews(id);
    }
}
